package org.googlecode.jwf.demo;

import java.awt.BorderLayout;
import java.awt.GridLayout;

import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextArea;
import javax.swing.border.EmptyBorder;

public class IntroPanel extends JPanel {

    public IntroPanel() {
        setupUI();
    }

    private void setupUI() {
        setLayout(new BorderLayout());

        add(new JLabel(new ImageIcon(getClass().getResource("clouds.jpg"))),
                BorderLayout.WEST);

        JPanel introPanel = new JPanel(new GridLayout(0, 1));

        JTextArea introArea = createLabelLikeTextArea("\nWelcome to the Wizard Dialog!\n\n\n"
                + "This is an example of a wizard dialog, which allows a user to traverse"
                + " a number of panels (while entering data) until the wizard has enough "
                + "information to perform whatever end function is necessary. \n\nNote that"
                + " panels are not necessarily ordered in a linear fashion, but instead in"
                + " a tree-like manner (e.g., there may be more than one panel with a"
                + " 'Finish' button, and it depends on the user's entries as to how they "
                + "traverse the path). \n\nThat's not the case with this example, however."
                + "\n\n\n\nPress the 'Next' button to continue....");
        introPanel.add(introArea);

        add(introPanel, BorderLayout.CENTER);
    }

    private JTextArea createLabelLikeTextArea(String text) {
        JTextArea textArea = new JTextArea(text);

        textArea.setFocusable(false);
        textArea.setOpaque(false);
        textArea.setEditable(false);

        textArea.setFont(new JLabel().getFont());

        textArea.setLineWrap(true);
        textArea.setWrapStyleWord(true);
        textArea.setBorder(new EmptyBorder(5, 10, 5, 10));

        return textArea;
    }
}
